require ( "gui" )

resx = 800
resy = 600

display:create ( "AGen Demos", resx, resy, 32, true )

gui.create ( )

local window1 = gui.Window ( 150, 175, 500, 350 )
gui.container:add_child ( window1 )

local label1 = gui.Label ( 20, 20, "AGen Demonstration Suite" )
label1.node.depth = -1
window1:add_child ( label1 )

local list1 = gui.List ( 10, 50, 480, 14 )
list1.node.depth = -1
window1:add_child ( list1 )
list1:add_items ( "1. Moving and rotating sprites" )
list1:add_items ( "2. Culling" )
list1:add_items ( "3. Fluid dynamics" )
list1:add_items ( "4. SVG Lion" )
list1:add_items ( "5. SVG Tiger" )
list1:add_items ( "6. Pathfinding" )
list1:add_items ( "7. Box2D constants" )
list1:add_items ( "8. Physics" )
list1:add_items ( "9. Device enumeration" )
list1:add_items ( "10. Cellular automation" )
list1:add_items ( "11. Interactive Lua console" )

function list1:on_select ( i )
    gui.container:destroy_children ( )
    gui.destroy ( )
    if i == 1 then
        dofile ( "Scripts/Demos/bench.lua" )
    elseif i == 2 then
        dofile ( "Scripts/Demos/cull.lua" )
    elseif i == 3 then
        dofile ( "Scripts/Demos/fluid.lua" )
    elseif i == 4 then
        dofile ( "Scripts/Demos/lion.lua" )
    elseif i == 5 then
        dofile ( "Scripts/Demos/tiger.lua" )
    elseif i == 6 then
        dofile ( "Scripts/Demos/micropather.lua" )
    elseif i == 7 then
        dofile ( "Scripts/Demos/box2d.lua" )
    elseif i == 8 then
        dofile ( "Scripts/Demos/physics.lua" )
    elseif i == 9 then
        dofile ( "Scripts/Demos/devices.lua" )
    elseif i == 10 then
        dofile ( "Scripts/Demos/ca.lua" )
    elseif i == 11 then
        dofile ( "Scripts/Demos/console.lua" )
    end
end


local button1 = gui.Button ( 20, 300, "Start" )
button1.node.depth = -1
window1:add_child ( button1 )

function button1:on_click ( b )
    local i = list1.index
    if i > 0 then
      list1:on_select ( i )
    end
end